package jgrit.gui;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;

import jgrit.gui.factory.UIFactory;
import jgrit.options.OptionCollection;

import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class GraphicsOptionsPanel extends javax.swing.JPanel {
	/**
	 * Auto-generated serialization version ID
	 */
	private static final long serialVersionUID = 5164890286187897694L;
	
	private JComboBox gfxOutputType;
	private JComboBox gfxBpp;
	private JTextField gfxTransColor;
	private JComboBox gfxCompression;

	/**
	* Auto-generated main method to display this 
	* JPanel inside a new JFrame.
	*/
	@SuppressWarnings("deprecation")
	public static void main(String[] args) {
		OptionCollection options = new OptionCollection();
		options.graphicsCompression.setValue("RLE");
		
		JFrame frame = new JFrame();
		frame.getContentPane().add(new GraphicsOptionsPanel(options));
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
	/**
	 * Create the panel with a new option collection
	 */
	@Deprecated
	public GraphicsOptionsPanel() {
		this(new OptionCollection());
	}
	
	/**
	 * Create the panel with an existing option collection
	 * 
	 * @param options
	 */
	public GraphicsOptionsPanel(OptionCollection options) {
		super();
		initGUI(options);
	}
	
	private void initGUI(OptionCollection options) {
		try {
			FormLayout thisLayout = new FormLayout(
					"max(p;5dlu), max(p;5dlu), 5dlu, max(p;5dlu), max(p;5dlu)", 
					"max(p;5dlu), max(p;5dlu), 5dlu, max(p;5dlu), max(p;5dlu), max(p;5dlu), 5dlu, max(p;5dlu), 5dlu");
			this.setLayout(thisLayout);
			
			{
//				ComboBoxModel gfxOutputTypeModel = 
//					new DefaultComboBoxModel(
//							new String[] { "tile", "bitmap" });
				gfxOutputType = new JComboBox();
				this.add(gfxOutputType, new CellConstraints("4, 2, 1, 1, default, default"));
//				gfxOutputType.setModel(gfxOutputTypeModel);
				UIFactory.attachOption(options.format, gfxOutputType);
			}
			{
				final JLabel jLabel1 = new JLabel();
				this.add(jLabel1, new CellConstraints("2, 4, 1, 1, default, default"));
				jLabel1.setText(options.bitDepth.getName());
			}
			{
//				ComboBoxModel gfxBppModel = 
//					new DefaultComboBoxModel(
//							new Integer[] { 1, 2, 4, 8, 16 });
				gfxBpp = new JComboBox();
				this.add(gfxBpp, new CellConstraints("4, 4, 1, 1, default, default"));
//				gfxBpp.setModel(gfxBppModel);
				UIFactory.attachOption(options.bitDepth, gfxBpp);
			}
			{
				final JLabel jLabel2 = new JLabel();
				this.add(jLabel2, new CellConstraints("2, 6, 1, 1, default, default"));
				jLabel2.setText("Compression");
			}
			{
				final JLabel jLabel3 = new JLabel();
				this.add(jLabel3, new CellConstraints("2, 8, 1, 1, default, default"));
				jLabel3.setText(options.transColor.getName());
			}
			{
//				ComboBoxModel gfxCompressionModel = 
//					new DefaultComboBoxModel(
//							new String[] { "off", "lz77", "huff", "rle", "off+hdr" });
				gfxCompression = new JComboBox();
				this.add(gfxCompression, new CellConstraints("4, 6, 1, 1, default, default"));
//				gfxCompression.setModel(gfxCompressionModel);
				UIFactory.attachOption(options.graphicsCompression, gfxCompression);
			}
			{
				final JLabel jLabel4 = new JLabel();
				this.add(jLabel4, new CellConstraints("2, 2, 1, 1, default, default"));
				jLabel4.setText("Output type");
			}
			{
				gfxTransColor = new JTextField();
				this.add(gfxTransColor, new CellConstraints("4, 8, 1, 1, default, default"));
				UIFactory.attachOption(options.transColor, gfxTransColor);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
